package com.example.mybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatisplus.mapper.OrderMapper;
import com.example.mybatisplus.model.domain.Orders;
import com.example.mybatisplus.mapper.OrdersMapper;
import com.example.mybatisplus.model.dto.PageDTO;
import com.example.mybatisplus.service.OrdersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author blue
 * @since 2022-01-07
 */
@Service
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements OrdersService {

    @Autowired
    private OrdersMapper ordersMapper;
    @Override
    public Page<Orders> listByPage(PageDTO page, Orders orders) {
        Page<Orders> page1 = new Page<>(page.getPageNo(), page.getPageSize());
        QueryWrapper<Orders> wrapper = new QueryWrapper<>();
        if (orders.getUserId() != null) {
            wrapper.lambda().eq(Orders::getUserId, orders.getUserId());
        }
        System.out.println(wrapper);
        page1 = ordersMapper.selectPage(page1, wrapper);
        return page1;
    }
}
